﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ResourceEditor.aspx.cs"
    Inherits="Atomic.Web.Pages.Sys.ResourceEditor" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" language="javascript">
        $(function () {
            var ID = '<%=Request["ID"] %>'; //预编辑项ID
            var PID = '<%=Request["PID"] %>';   //父节点ID
            if (PID == '' || PID == 0) {
                $('#ParentDisplay').hide();
            } else {
                //父节点名称
                $.post('/Handlers/Sys/ResourceHandler.ashx/?method=GetResourceName',
                {
                    PID: PID
                },
                function (data) {
                    $('#ParentName').text(data);
                },
                'json');
            }

            //预编辑加载
            if (ID > 0) {
                //节点基本信息
                $.post('/Handlers/Sys/ResourceHandler.ashx/?method=GetResource',
                {
                    ID: ID
                },
                function (data) {
                    if (data != null) {
                        $('#Key').val(data.Key);
                        $('#Name').val(data.Name);
                        $('#Url').val(data.Url);
                        $('#Sort').val(data.Sort);
                        $('#Cls').val(data.Cls);
                        $('#Enabled').attr('checked', data.Enabled == '1');
                    }
                },
                'json');
            }

            //保存事件
            $('#btnSubmit').linkbutton().click(function () {
                $.post('/Handlers/Sys/ResourceHandler.ashx/?method=AddResource',
                {
                    ID: ID,
                    Key: $('#Key').val(),
                    PID: PID,
                    Name: $('#Name').val(),
                    Url: $('#Url').val(),
                    Sort: $('#Sort').val(),
                    Cls: $('#Cls').val(),
                    Enabled: $('#Enabled').attr('checked') ? 1 : 0
                },
                function (data) {
                    if (data.Success) {
                        try {
                            OnResourceEditSuccess();
                        } catch (e) {
                        }
                    } else {
                        $.messager.alert('提示信息', data.Message, 'warning');
                    }
                },
                'json');
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <table id="resourceEditorForm">
        <tr>
            <td>
                唯一键
            </td>
            <td>
                <input type="text" id="Key" value="" class="easyui-validatebox" required="true" />
            </td>
        </tr>
        <tr id="ParentDisplay">
            <td>
                父节点
            </td>
            <td>
                <span id="ParentName"></span>
            </td>
        </tr>
        <tr>
            <td>
                名称
            </td>
            <td>
                <input type="text" id="Name" value="" class="easyui-validatebox" required="true" />
            </td>
        </tr>
        <tr>
            <td>
                地址
            </td>
            <td>
                <input type="text" id="Url" value="" />
            </td>
        </tr>
        <tr>
            <td>
                顺序
            </td>
            <td>
                <input type="text" id="Sort" value="0" />
            </td>
        </tr>
        <tr>
            <td>
                样式
            </td>
            <td>
                <input type="text" id="Cls" value="" />
            </td>
        </tr>
        <tr>
            <td>
                启用
            </td>
            <td>
                <input type="checkbox" id="Enabled" />
            </td>
        </tr>
        <tr>
            <td>
            </td>
            <td>
                <a id="btnSubmit" href="javascript:void(0);">提 交</a>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
